<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('学生选题临时列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>题目名称：</label>
                                <input type="text" name="thesisTitle.thesisName"/>
                            </li>
                            <li>
                                <label>教师工号：</label>
                                <input type="text" name="studentUser.loginName"/>
                            </li>
                            <li>
                                <label>学生学号：</label>
                                <input type="text" name="studentUser.loginName"/>
                            </li>
                            <li>
                                <label>审批状态：</label>
                                <select name="status" class="form-control m-b" th:with="type=${@dict.getType('thesis_select_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="thesis:tmp:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var selectFlag = [[${@permission.hasPermi('thesis:tmp:select')}]];
        var editFlag = [[${@permission.hasPermi('thesis:tmp:edit')}]];
        var removeFlag = [[${@permission.hasPermi('thesis:tmp:remove')}]];
        var datas = [[${@dict.getType('thesis_select_status')}]];
        var prefix = ctx + "thesis/tmp";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "学生选题临时",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'tmTempId',
                    title: '*',
                    visible: false
                },
                {
                    field: 'thesisTitle.thesisName',
                    title: '题目名称'
                },
                {
                    field: 'teacherUser.userName',
                    title: '指导教师'
                },
                {
                    field: 'studentUser.userName',
                    title: '学生姓名'
                },
                {
                    field: 'status',
                    title: '审批状态',
                    formatter: function(value, item, index) {
                        return $.table.selectDictLabel(datas, item.status);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.status == '0'){
                            actions.push('<a class="btn btn-success btn-xs ' +  selectFlag + '" href="javascript:void(0)" onclick="select(\'' + row.tmTempId + '\',\''+ row.thesisId + '\',\''+ 1 + '\')"><i class="fa fa-edit"></i>确认</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + selectFlag + '" href="javascript:void(0)" onclick="select(\'' + row.tmTempId + '\',\''+ row.thesisId + '\',\''+ 2 + '\')"><i class="fa fa-edit"></i>拒绝</a> ');
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.tmTempId + '\')"><i class="fa fa-remove"></i>撤销</a>');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
    <script th:inline="javascript">
        function select(id,thesisId,status) {
            $.modal.confirm("确认该学生选择该论文题目吗？", function() {
                var data = {
                    "tmTempId":id,
                    "thesisId":thesisId,
                    "status":status
                }
                $.operate.post("/thesis/tmp/chooseOperate",data);
            });

        }
    </script>
</body>
</html>